package com.dullfox.sbm.common.global;

import com.dullfox.sbm.common.auth.AuthException;
import com.dullfox.sbm.common.bean.Result;
import com.dullfox.sbm.common.util.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Author: zengdy
 * Date: 2018/10/25
 */
@ControllerAdvice
public class RunExceptionHandler {

    @ExceptionHandler(value = RunException.class)
    @ResponseBody
    public Result handlerRunException(RunException e) {
        return ResultUtil.error(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(value = AuthException.class)
    @ResponseBody
    public Result handlerAuthException(AuthException e) {
        return ResultUtil.error(e.getCode(), e.getMessage());
    }

}
